﻿<script language="JavaScript"> 
     var HiddenEditPageName;
     
     var tgs;
     var tmp_background_val; 
     function tog(n,flags)
     { 
         if (tgs){
          tgs.style.background= tmp_background_val ; 
        } 
        n.style.background= '#99ccff' ;
        tmp_background_val=flags;
        tgs=n;
    }

    function GetRowIndex(obj)
    {
        $('<%=HiddenID.ClientID %>').value = obj;
    }

    var HiddenID;
    function checkSelect()
    {
        HiddenID=$('<%=HiddenID.ClientID %>').value;
        if(isNull(HiddenID))
        {
            alert("请选择一条记录!");
        }
        return !isNull(HiddenID);
    }

    function CheckAll(spanChk)//CheckBox全选
    {
        var oItem = spanChk.children;
        var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
        xState=theBox.checked;
        elm=theBox.form.elements;
        for(i=0;i<elm.length;i++)
        if(elm[i].type=="checkbox" && elm[i].id !='ckLocalPoint' && elm[i].id!=theBox.id)
        {
            if(elm[i].checked!=xState)
            elm[i].click();
        }
    }
    
    //获取被选中的ID列表
    function GetChecedIDS()
    {
         var ids = "";  
      
         var cbxList = document.getElementsByTagName("input");
         for(var i=0;i<cbxList.length;i++)
         {
            if( cbxList[i].type == "checkbox" && cbxList[i].id != 'GridView1_ctl01_checkAll' && cbxList[i].checked) 
            {    
               if(ids.length > 0)
                   ids=ids +",";      
               ids= ids + cbxList[i].value ;
                
            }
         } 
         
         return ids;     
    }
    //---------------------------------------------------------
    
    //查看
    function View()
    {
        if(checkSelect())
        {
            var url=$('HiddenViewPageName').value +"?ID= " + HiddenID;
            showDialog(url);
        }
    }
    //添加
    function Add()
    {
        var url=$('HiddenEditPageName').value + "?EditStatus=1" ;
        showDialog(url);
        RefreshData();
    }
    //编辑
    function Edit()
    {
        if(checkSelect())
        {
            var url=$('HiddenEditPageName').value + "?ID=" + HiddenID  + "&EditStatus=2";
            showDialog(url);
            RefreshData();
        }
    }
    //归档
    function Trad()
    {
        if(checkSelect())
        {
            var url=$('HiddenEditPageName').value + "?ID=" + HiddenID  + "&EditStatus=2";
            showDialog(url);
            RefreshData();
        }
    }
      //放弃归档
    function Notrad()
    {
        if(checkSelect())
        {
            var url=$('HiddenEditPageName').value + "?ID=" + HiddenID  + "&EditStatus=2";
            showDialog(url);
            RefreshData();
        }
    }
    
    //弹出打开新页面
    function winOpen(url)
    {
       
      
        var sFeatures='height='+$('HiddenHeight').value+', width='+$('HiddenWidth').value+', top=40, left=50,toolbar=0, menubar=0, scrollbars=yes, resizable=1, location=0, status=0';
        window.open(url,"PM_Base",sFeatures);
    }

    //模态弹出打开新页面
    function showDialog(url)
    {
        var sFeatures = "dialogHeight:"+$('HiddenHeight').value+"px;dialogWidth:"+$('HiddenWidth').value+"px;resizeable:no;help:no;status:no";
        var obj=showModalDialog(url,window,sFeatures); 
    }
    //刷新GridView数据
    function RefreshData()
    {       
	    var btnRefresh= document.getElementById("btnRefresh");
	    if(btnRefresh!=null)
	       btnRefresh.click();
    }
    //删除之前确认.
    function DeleteAffirm()
    {
      if(confirm('确定删除选中数据？'))  
          return true;
        else
          return false;
    }
    </script>